﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AGVControlSystemPro
{
    public partial class FrmIPEdit : Form
    {
        public FrmIPEdit()
        {
            InitializeComponent();
            //ip地址列表
            string hostname = Dns.GetHostName();
            IPHostEntry localhost = Dns.GetHostByName(hostname);
            //IPAddress localaddr = localhost.AddressList[0];
            this.lbIP.DataSource = localhost.AddressList;
            if (this.lbIP.Items.Count == 0)
            {
                this.btnSet.Enabled = false;
            }
        }

        private void btnSet_Click(object sender, EventArgs e)
        {
            if (this.lbIP.SelectedIndex == -1)
            {
                MessageBox.Show("请选择一项IP地址！", "信息提示");
                return;
            }
            CommonMethods.ServerLocalIP = this.lbIP.SelectedItem.ToString();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
